<?php
include_once "objs/User.php";
include_once "models/UserDao.php";
include_once "models/Util.php";
include_once "models/MySqlDataAccessHelper.php";

$leftContent = 'dangnhapleft.php';

$msgError = Util::getRequestParam('error');

$user = NULL;
$act = Util::getRequestParam('act');
if ($act == 'login') {
    $userName = Util::getRequestParam('username');
    $passwd = Util::getRequestParam('password');

    if (strlen($userName) > 0) {
        $md5Pass = md5($passwd);
        $user = UserDao::getUser($userName, $md5Pass);
        if ($user == NULL) {
            $msgError = 'Sai email hoặc mật khẩu!';
        }else{
            //Util::startSession();
            $_SESSION['user'] = $user;
            echo "<script>location.href='index.php'</script>";
        }
    } else {
        $msgError = 'Bạn hãy nhập email!';
    }
}
include 'subs/template.php';
?>

